﻿using Microsoft.AspNetCore.Mvc;
using SMARTHOTEL.hotel;
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace SMARTHOTEL.Staies
{


    /// <summary>
    /// 住宿信息
    /// </summary>
    [ApiExplorerSettings(GroupName = "v2")]
    public class StayService:ApplicationService, IStayService
    {
        IRepository<Stay> stayRep;

        public StayService(IRepository<Stay> stayRep)
        {
            this.stayRep = stayRep;
        }

        /// <summary>
        /// 添加住宿信息
        /// </summary>
        /// <param name="stayDto"></param>
        /// <returns></returns>
        public async Task<ResultDto<bool>> CreateAllAsync(CreateUpdateStayDto stayDto)
        {
            try
            {
                Stay staies = ObjectMapper.Map<CreateUpdateStayDto, Stay>(stayDto);
                await stayRep.InsertAsync(staies);
                return new ResultDto<bool> { Data = true, Code = StatusCode.Success, Message = "添加成功" };
            }
            catch (Exception ex)
            {
                return new ResultDto<bool> { Data = true, Code = StatusCode.Success, Message = "添加失败"+ex.Message };
            }
        }
    }
}
